unit uLang;

interface

uses
  System.Classes;
{ TLang }

Type

  LANG_TYPE = (EN, CH);

  PLang = ^ZLang;
  ZLang = class
  private
    m_lang: LANG_TYPE;
    m_strList_EN: TStrings;
    m_strList_CH: TStrings;
    //m_fileName: string;
    procedure SetLang(const langType: LANG_TYPE);
    function GetLangStr(const Index: string): string;
  public
    constructor Create(langType: LANG_TYPE = EN);
    destructor Destroy;

    property Lang: LANG_TYPE read m_lang write SetLang;
    property ResourcesEN: TStrings read m_strList_EN;
    property ResourcesCH: TStrings read m_strList_CH;
    property LangStr[const Index: string]: string read GetLangStr;
    procedure SetLangStr(Index: string; const value_EN: string; const value_CH: string);

    //property FileName: string read m_fileName write m_fileName;
    //procedure LoadFromFile(const AFileName: string);
    //procedure SaveToFile(const AFileName: string);
    //procedure ReadResources(Stream: TStream);
    //procedure WriteResources(Stream: TStream);
  end;
implementation

{ TLang }


constructor ZLang.Create(langType: LANG_TYPE);
begin
  m_lang := langType;
  m_strList_EN := TStringList.Create;
  m_strList_CH := TStringList.Create;
end;

destructor ZLang.Destroy;
begin
  m_strList_EN.Free;
  m_strList_CH.Free;
end;

procedure ZLang.SetLang(const langType: LANG_TYPE);
begin
  if m_lang <> langType then
    m_lang := langType;
end;

function ZLang.GetLangStr(const Index: string): string;
begin
  if m_lang = EN then
    Result := m_strList_EN.Values[Index]
  else if m_lang = CH then
    Result := m_strList_CH.Values[Index];
end;


procedure ZLang.SetLangStr(Index: string; const value_EN: string; const value_CH: string);
begin
  m_strList_EN.Values[Index] := value_EN;
  m_strList_CH.Values[Index] := value_CH;
end;

end.
